function IdCard(UUserCard, num) {

  if (num == 1) {  //获取出生日期  
    var birth = UUserCard.substring(6, 10) + "-" + UUserCard.substring(10, 12) + "-" + UUserCard.substring(12, 14);
    return birth;
  }
  if (num == 2) {   //获取性别
    if (parseInt(UUserCard.substr(16, 1)) % 2 == 1) {
       return "男";
    } else {
      return "女";

    }

  }
  if (num == 3) {

    //获取年龄

    var myDate = new Date();

    var month = myDate.getMonth() + 1;

    var day = myDate.getDate();

    var age = myDate.getFullYear() - UUserCard.substring(6, 10) - 1;

    if (UUserCard.substring(10, 12) < month || UUserCard.substring(10, 12) == month && UUserCard.substring(12, 14) <= day) {

      age++;

    }

    return age;

  }
  if (num == 4) {

		  UUserCard = UUserCard.split('');  
		//∑(ai×Wi)(mod 11)  
		//加权因子  
		 var factor = [7, 9, 10, 5, 8, 4, 2, 1, 6, 3, 7, 9, 10, 5, 8, 4, 2];  
		 var parity = [1, 0, 'X', 9, 8, 7, 6, 5, 4, 3, 2];  
		var sum = 0;  
		var ai = 0;  
		var wi = 0;  
		for (var i = 0; i < 17; i++) {   
		ai =UUserCard[i];   
		 wi = factor[i];   
		sum += ai * wi;  
		 }  
		var last = parity[sum % 11];  
		var tip="ok";
		if (last!=UUserCard[17]) {   
			
			tip = "error"; 
			//pass = false;   
		 }  
		 	return tip
				
	 } 
	  

  }



module.exports={

  IdCard : IdCard

}

